﻿//========================================================================//
//      Copyright 2012, Smilodon Studio Inc.
//      All rights reserved.
//========================================================================//

/**
 *	tunnel
 *      @author: CYS
 */


var guiBox = function()
{
	this.color = [ 255, 255, 255, 1.0 ];
	this.a = 0.05;
	this.b = 0.03;
	this.c = -0.2;
	this.movex = 150;
	this.movey = 150;
	this.segments = 40;
};


var a = 0, b = 0, c = 0;
function tunnel(g2D)
{
	var text = new guiBox();

	for (i = 0; i < 40; i++)
	{
		r1 = text.movex + i * Math.sin(a);
		r2 = text.movey + i * Math.cos(b);
		x = width / 2 + Math.cos(a + i * 0.1) * r1;
		y = height / 2 + Math.sin(b + i * 0.1) * r2;

		g2D.fillStyle = rgba(
			text.color[0]*(sin(i*1.1 + c) * 0.5 + 0.5),
			text.color[1]*(sin(i*1.3 + c) * 0.4 + 0.6),
			text.color[2]*(sin(i + c) * 0.7 + 0.3),
			1);

		for (var j = 0; j < text.segments; j++)
		{
			g2D.beginPath();
			g2D.arc(x + Math.cos(Math.PI * 2 / text.segments * j) * i * 28,
			      y + Math.sin(Math.PI * 2 / text.segments * j) * i * 28,
			      i * 0.5, 0, Math.PI * 2, true);
			g2D.fill();
		}
	}

	a += text.a;
	b += text.b;
	c += text.c;
}